package com.zzyl.nursing.job;

import com.zzyl.nursing.domain.DeviceData;
import com.zzyl.nursing.mapper.DeviceDataHistoryMapper;
import com.zzyl.nursing.mapper.DeviceDataMapper;
import com.zzyl.nursing.service.IDeviceDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component("UpdateDeleteDeviceDate")
public class UpdateDeleteDeviceDate {
    @Autowired
    private IDeviceDataService deviceDataService;
    @Autowired
    private DeviceDataHistoryMapper deviceDataHistoryMapper;
    @Autowired
    private DeviceDataMapper deviceDataMapper;
    public List<DeviceData> informationJob(){
        System.out.println("定时删除历史数据");
        List<DeviceData> datas = deviceDataService.selectDeviceDataTimeList();
        for (DeviceData datum : datas) {
            deviceDataHistoryMapper.insertDeviceDataHistory(datum);
            Long id = datum.getId();
            deviceDataMapper.deleteDeviceDataById(id);
        }

        return null;
    }
}
